package com.haipumi.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.haipumi.beans.haipumi_skin;
import com.haipumi.beans.haipumi_user;
import com.haipumi.biz.IBackSkinBiz;
import com.haipumi.dao.IBackSkinDao;
import com.haipumi.mapper.SkinMapper;


@Service("backSkinBiz")
public class BackSkinBizImpl implements IBackSkinBiz {
	
	@Autowired
	SkinMapper skinMapper;
	
	
	@Override
	public List<haipumi_skin> findAllSkin(int start,int end,String order,String sort) {
		Map<String,Object> map=new HashMap<String ,Object>();
		map.put("start",start);
		map.put("end", end);
		map.put("order", order);
		map.put("sort",sort);
		List<haipumi_skin>skinlist=skinMapper.findAllSkin(map);
		return skinlist;
	}

	@Override
	public int countAllSkin(int start,int end,String order,String sort) {
		int r=0;
		Map<String,Object> map=new HashMap<String ,Object>();
		map.put("start",start);
		map.put("end", end);
		map.put("order", order);
		map.put("sort",sort);
		r=skinMapper.countAllSkin(map);
		return r;
	}

	@Override
	public haipumi_skin insertSkin(haipumi_skin skin) {
		Map<String,Object> map=new HashMap<String ,Object>();
		map.put("scolor",skin.getScolor());
		map.put("sstatus", Integer.parseInt(skin.getSstatus()));
		haipumi_skin  newskin=skinMapper.insertSkin(map);
		return newskin;
	}

	@Override
	public haipumi_skin updateSkin(haipumi_skin skin) {
		Map<String,Object> map=new HashMap<String ,Object>();
		map.put("simage", skin.getSimage());
		map.put("scolor", skin.getScolor());
		map.put("sstatus", Integer.parseInt(skin.getSstatus()));
		map.put("sid", Integer.parseInt(skin.getSid()));
		int result=skinMapper.updateSkin(map);
		if(result>0){
			return skinMapper.findSkin(Integer.parseInt(skin.getSid()));
		}
		return skin;
	}

	@Override
	public List<haipumi_skin> findAllDisplaySkin() {
		return skinMapper.findAllDisplaySkin();
	}

}
